home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / drdobbs / 1987 / 12 / naro / naro.exp < prev    next >
Text File  |  1987-11-13  |  5KB  |  163 lines

  1.  
  2.  
  3.   /*   This program demonstrates the use of the LOCATE utility. It
  4.        contains all of the components of a typical C program to exercise
  5.        the startup code and locate utility.
  6. */
  7.  
  8. char    *ptr = "class DATA" ;             /* Initialized data */
  9. int array[10][10]  ;                      /* Uninitialized data */
  10.  
  11. main()
  12. {
  13.     int i,  j ;                           /* Automatics */
  14.     static  char    *s = "" ;             /* Static initialized data */
  15.  
  16.     for (i = 0; i < 10; i++)    {
  17.         for (j = 0; j < 10; j++)
  18.             array[i][j] = i * j ;
  19.     }
  20.  
  21.     strcpy(s, ptr)  ;           /* Bring in a library function */}
  22.  
  23. Example 1: The demonstration program
  24.  
  25.  
  26.  
  27.    C>masm /MX tc, tc, tc ;
  28.    Microsoft (R) Macro Assembler  Version 4.00
  29.    Copyright (C) Microsoft Corp 1981, 1983, 1984, 1985.  All rights reserved.
  30.  
  31.      49272 Bytes symbol space free
  32.         0 Warning Errors
  33.         0 Severe  Errors
  34.  
  35.    C>tcc -c -ml demo
  36.    Turbo C  Version 1.0  Copyright (c) 1987 Borland International
  37.    demo.c:
  38.  
  39.           Available memory 293342
  40.  
  41. Example 2: Compiling the C source code and the MASM start-up module
  42.  
  43.  
  44.  
  45.  
  46. C>type demo.map
  47.  
  48.  Start   Stop    Length  Name             Class
  49.  
  50.  00000H  00035H  00036H  _TEXT            CODE
  51.  00036H  0007FH  0004AH  DEMO_TEXT        CODE
  52.  00080H  000A8H  00029H  STRCPY_TEXT      CODE
  53.  000B0H  000BFH  00010H  _ETEXT           CODEEND
  54.  000C0H  000D3H  00014H  _DATA            DATA
  55.  000E0H  001A7H  000C8H  _BSS             BSS
  56.  001A8H  001A8H  00000H  _BSSEND          BSSEND
  57.  001B0H  003AFH  00200H  _STACK           STACK
  58.  
  59.  
  60.  Address           Publics by Value
  61.  
  62.  0000:0000         START
  63.  0003:0006         _MAIN
  64.  0008:0000         _STRCPY
  65.  000B:0010         TEND
  66.  000C:0000         _PTR
  67.  000C:0000         IDATA
  68.  000C:0020         ARRAY
  69.  000C:0020         BDATA
  70.  000C:00E8         EDATA
  71.  001B:0200         TOS
  72.  
  73. Program entry point at 0000:0000
  74.  
  75. Example 3: The linker map file
  76.  
  77.  
  78.  
  79.  
  80. ;
  81. ;       This configuration file is used with Turbo C to build a ROMable
  82. ;       image. It defines physical addresses for three classes, makes a
  83. ;       copy of the initialized data class to keep in ROM and instructs
  84. ;       the locator the order of the different classes.
  85. ;
  86.  
  87. dup     DATA CONST         ; Make a copy of the initialized data class
  88.                            ; and name it CONST
  89.  
  90. class  CODE = 0xfc00       ; Start code at address FC000H
  91. class  STACK = 0x0080      ; The stack at address 00800H
  92. class  DATA = 0x0100       ; DGROUP at address 01000H
  93. order  DATA BSS BSSEND     ; Define the order of DGROUP
  94. order CODE CODEEND CONST   ; And the order of classes in ROM
  95.  
  96. rom CODE CONST             ; ROM only the program code and the copy
  97.                            ; of the initialized data that the startup
  98.                            ; code copies from ROM to DGROUP
  99.  
  100. Example 4: The configuration file
  101.  
  102.  
  103.  
  104.  
  105. C>type demo.loc
  106. MS-DOS Locate Utility Version 1.0
  107.  
  108. Input File: DEMO.EXE
  109. Output File: DEMO.HEX
  110. Configuration File: DEMO.CFG
  111. Invoked by: C:\BIN\LOCATE.EXE -b demo
  112. Date/Time: Mon Aug 03 14:40:17 1987
  113.  
  114. Segment Information
  115. Name         Class         Address     Length_
  116. TEXT         CODE          FC000H      0036H
  117. DEMO_TEXT    CODE          FC036H      004AH
  118. STRCPY_TEX   CODE          FC080H      0029H
  119. _ETEXT       CODEEND       FC0B0H      0010H
  120. _DATA        DATA          01000H      0014H
  121. _BSS         BSS           01020H      00C8H
  122. _BSSEND      BSSEND        010E8H      0000H
  123. _STACK       STACK         00800H      0200H
  124. _DATA        NEWDATA       FC0C0H      0014H
  125. ??BOOT       (ABSOLUTE)    FFFF0H      0005H
  126.  
  127. Public Symbols
  128. FC00:0000  START                 FC03:0006  _MAIN
  129. FC08:0000  _STRCPY               FC0B:0010  TEND
  130. 0100:00E8  EDATA                 0100:0020  BDATA
  131. 0100:0020  _ARRAY                0100:0000  IDATA
  132. 0100:0000  _PTR                  0080:0200  TOS
  133.  
  134. Entry Point - FC00:0000
  135.  
  136. Example 5: The ouput from the locator
  137.  
  138.  
  139.  
  140. :02000002FC0000
  141. :10000000FAB880008ED0BC0002B800018EC0B80BD8
  142. :10001000FC408ED8BE00008BFEB920002BCFF3A48D
  143. :10002000061F32C0BF2000B9E8002BCFF3AAFB9A0D
  144. :06003000060003FCEBCA10
  145. :02000002FC03FD
  146. :10000600565733F6EB2433FFEB1A8BC6F7E7508BC4
  147. :10001600C6BA1400F7E28BD88BC7D1E003D858894B
  148. :100026008720004783FF0A7CE14683FE0A7CD7FFD0
  149. :10003600360200FF360000FF360600FF3604009A3F
  150. :0A004600000008FC83C4085F5ECBD5
  151. :02000002FC08F8
  152. :100000005657558BECFC1EC47E0E8BF732C0B9FFE1
  153. :10001000FFF2AEF7D18CC38EDBC47E0AF3A41F8B34
  154. :09002000560C8B460A5D5F5ECBB5
  155. :02000002FC0CF4
  156. :100000000800000113000001436C61737320444138
  157. :040010005441000057
  158. :02000002FFFFFE
  159. :05000000EA000000FC15
  160. :04000003FC000000FD
  161. :00000001FF
  162.  
  163.